package com.atguigu.gulimall.search.controller;

import com.atguigu.gulimall.search.service.ProductSaveService;
import com.guigui.common.dto.elastic.SkusElasticModel;
import com.guigui.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xin
 */
@RestController
@RequestMapping("/search")
public class ElasticController {

    @Autowired
    private ProductSaveService productSaveService;


    @PostMapping("/save")
    public R productSaveAndUp(@RequestBody List<SkusElasticModel> elasticModels) {

        boolean save = productSaveService.save(elasticModels);

        return save ? R.ok() : R.error();
    }
}
